#include <sys/system.h>
#include <gal/ptgui.h>
#include <gal/surface.h>
#include <gal/font.h>
#include <gal/region.h>
#include <pages/pagectl.h>
#include <widgets/widget.h>
#include <widgets/container.h>
#include <pages/page.h>

#include <SDL/SDL.h>
#include <stdlib.h>

extern ptgui_surface_t screen;
void pt_gui_system_init(void *user_data)
{
	pt_uint16_t w, h;
	pt_uint16_t desired_bpp;
	pt_uint32_t video_flags;

	w = 800;
	h = 480;
	desired_bpp = 0;
	video_flags = 0;

	if ( SDL_Init(SDL_INIT_VIDEO, user_data) < 0 ) {
		fprintf(stderr,
			"Couldn't initialize SDL: %s\n", SDL_GetError());
		exit(1);
	}
	atexit(SDL_Quit);			/* Clean up on exit */

	screen.backend = SDL_SetVideoMode(w, h, desired_bpp, video_flags);
	if ( screen.backend == PT_NULL ) {
		fprintf(stderr, "Couldn't set %dx%dx%d video mode: %s\n",
					w, h, desired_bpp, SDL_GetError());
		exit(1);
	}

	ptgui_font_system_init();
	ptgui_type_system_init();
	ptgui_page_system_init();
}

